<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ilib_build</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : May 2000</div>
    <p>
      <b>ilib_build</b> -  utility for shared library management</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>ilib_build(lib_name,table,files,libs [,makename,ldflags,cflags,fflags])  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>lib_name</b>
        </tt>: a character string, the generic name of the library without path and extension.</li>
      <li>
        <tt>
          <b>table</b>
        </tt>: 2 column string matrix giving the table of pairs 'scilab-name', 'interface name'</li>
      <li>
        <tt>
          <b>files</b>
        </tt>: string matrix giving objects files needed for shared library creation</li>
      <li>
        <tt>
          <b>libs</b>
        </tt>: string matrix giving extra libraries needed for shred library creation</li>
      <li>
        <tt>
          <b>makename</b>
        </tt>: character string. The path of the Makefile file without extension.</li>
      <li>
        <tt>
          <b>ldflags,cflags,fflags</b>
        </tt>: character strings to provide options for the loader, the C compiler and the Fortran compiler.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    This tool is used to create shared libraries and to generate a 
    loader file which can be used to dynamically load the shared library 
    into Scilab with <tt>
        <b>addinter</b>
      </tt>
    </p>
    <p>
    Many examples are provided in <tt>
        <b>examples/interface-tour-so</b>
      </tt>
    directory.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

//Here with give a complete example on adding new primitive to Scilab
//create the procedure files
f1=['extern double fun2();'
    'void fun1(x,y)'
    'double *x, *y;'
    '{*y=fun2(*x)/(*x);}'];

mputl(f1,'fun1.c')

f2=['#include &lt;math.h&gt;'
    'double fun2(x)'
    'double x;'
    '{ return( sin(x+1.));}'];
mputl(f2,'fun2.c');

//creating the interface file
i=['#include ""stack-c.h""'
   'extern int fun1 _PARAMS(( double *x, double *y));'
   'int intfun1(fname)' 
   'char * fname;'
   '{'
   '  int m1,n1,l1;'
   '  CheckRhs(1,1);'
   '  CheckLhs(1,1);'
   '  GetRhsVar(1, ""d"", &amp;m1, &amp;n1, &amp;l1);'
   '  fun1(stk(l1),stk(l1));'
   '  LhsVar(1) = 1;'
   '  return 0;'
   '}'];
mputl(i,'intfun1.c')

//creating the shared library (a gateway, a Makefile and a loader are 
//generated. 

files=['fun1.o','fun2.o','intfun1.o'];
ilib_build('foo',['scifun1','intfun1'],files,[]);

// load the shared library 

exec loader.sce 

//using the new primitive
scifun1(33)
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="../functions/addinter.htm">
        <tt>
          <b>addinter</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="link.htm">
        <tt>
          <b>link</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_compile.htm">
        <tt>
          <b>ilib_compile</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_Make.htm">
        <tt>
          <b>ilib_gen_Make</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_gateway.htm">
        <tt>
          <b>ilib_gen_gateway</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_loader.htm">
        <tt>
          <b>ilib_gen_loader</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_for_link.htm">
        <tt>
          <b>ilib_for_link</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
